#Harris 1972 Presidential Election and Economic Outlook Survey, study no. 2235

## packages 
require("dplyr")
require("readstata13")

## set replication package to 
## replication folder

## download data
survey <- read.dta13("Harris_Data/Harris 1972 Presidential Election and Economic Outlook Survey, study no. 2235/harris_s2235_spss.dta")


## pid
survey$pid <- c(1:nrow(survey))
class(survey$pid)

## study number
survey$study <- as.character(2235)
class(survey$study)

## year
survey$year <- 1972
class(survey$year)

## geographpic data
summary(survey$S13)
survey$urban <- as.character(survey$S13)

## region 
summary(survey$S11)
survey$region <- as.character(survey$S11)
str(survey$region)

## respondent name
summary(survey$F1)
survey$hh <- as.character(survey$F1)

## inequality increasing
summary(survey$P6_A)
survey$inequality <- as.character(survey$P6_A)
str(survey$inequality)

## inequality variable version
survey$inequality.variable <- 1

## union 
summary(survey$F10_4) # not sure
table(survey$F10_4, survey$F10_1)

survey$union.self <- as.character(survey$F10_1)
survey$union.self[survey$F10_4 == "Yes"] <- "Not Sure"

survey$union.other <- as.character(survey$F10_2)
survey$union.other[survey$F10_4 == "Yes"] <- "Not Sure"

## Are you employed? what kind of employment?
summary(survey$F2A)
survey$employed <- as.character(survey$F2A)
str(survey$employed)

## employed.self
survey$employed.self <- NA

## Occupation
summary(survey$F2B)
survey$occupation <- as.character(survey$F2B)
str(survey$occupation)

## occupation.self
survey$occupation.self <- NA

## household size
survey$hhsize <- NA

## Education
summary(survey$F8)
survey$educ <- as.character(survey$F8)
str(survey$educ)

## Income
summary(survey$F9)
survey$income <- as.character(survey$F9)
str(survey$income)

## Age 
summary(survey$P1E)
survey$age <- as.character(survey$P1E)
str(survey$age)

## race
summary(survey$F11)
survey$race <- as.character(survey$F11)
str(survey$race)

## politics 
summary(survey$P1C)
survey$party <- as.character(survey$P1C)
str(survey$party)

## ideology
survey$ideology <- NA
summary(survey$ideology)

## gender
summary(survey$F12)
survey$gender <- as.character(survey$F12)
table(survey$gender)

## religion
summary(survey$F3)
survey$religion <- as.character(survey$F3)
str(survey$religion)

## factuals
survey$factual1 <- NA
survey$factual2 <- NA
survey$factual3 <- NA

## alienation index
survey$dontcare <- as.character(survey$P6_B)
survey$dontcount <- as.character(survey$P6_C)
survey$leftout <- as.character(survey$P6_E)

## question_place
survey$question_place <- "after party"


### put together data set
survey_2235 <- survey[,c("pid", "study", "year", "urban", "region", "hh",
                         "inequality", "inequality.variable", "union.self", "union.other",
                         "employed", "employed.self", "occupation", "occupation.self", "hhsize", "educ", "income", 
                         "age", "race", "party", "ideology", "gender", "religion",
                         "factual1", "factual2", "factual3", "dontcare", "dontcount", "leftout",
                         "question_place")]


## save dataset in folder (i.e. working directory must be set to folder)
#saveRDS(survey_2235, file = "Harris_Data/survey_2235.rds")



